package com.qt.socket.tcpwork.work1;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

/**
 * @Author zsf
 * @Date 2023/10/5 15:18
 * @Version 1.0
 */
public class TcpSendTest {

    /**
     * TCP通信练习1 ---多发多收
     * 客户端:多次发送数据
     * 服务器:接收多次接收数据，并打印
     */

    public static void main(String[] args) throws IOException {



        Scanner sc = new Scanner(System.in);
        Socket socket = new Socket("127.0.0.1", 8888);
        OutputStream os = socket.getOutputStream();

        while (true) {
            String str = sc.nextLine();
            os.write(str.getBytes());


            if("886".equals(str)){
                break;
            }
        }
        socket.close();


    }


}
